#ifndef FILEREADER_H
#define FILEREADER_H

#include <QObject>
#include <phonon>
#include <QtNetwork>

class FileReader : public QObject
{
Q_OBJECT
public:
    FileReader(QHostAddress address,int port);
    void requestFile(int mediaID);
    QByteArray * getData();
    QImage toImage();
    void getListing(QString param);
    QIODevice * getStreamingDevice();
signals:
    void downloadComplete(QByteArray * fileBuffer);
    void completed(QByteArray * fileBuffer);
private slots:
    void read();
    void complete();
    void connected();
    void write();
private:
    QByteArray response;
    QHostAddress address;
    int port;
    bool receivingFile;
    QTcpSocket * socket;
    QByteArray * fileBuffer;
    quint64 blockSize;
    QDataStream out;
    QBuffer * buffer;
};

#endif // FILEREADER_H
